package cn.donting.jme.edit.ui.inspector.imp.light;

import cn.donting.jme.edit.attribute.Attribute;
import cn.donting.jme.edit.ex.AttributeLoader;
import cn.donting.jme.edit.ex.ExResourcesLoad;
import cn.donting.jme.edit.ex.InspectorUILoader;
import cn.donting.jme.edit.ui.inspector.AttributeInspectorUI;
import cn.donting.jme.edit.ui.inspector.InspectorUI;
import com.jme3.light.AmbientLight;
import com.jme3.light.Light;
import com.jme3.light.LightList;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;
import java.util.ArrayList;
import java.util.List;

/**
 * light
 */
@Slf4j
public class LightInspectorUILoader implements InspectorUILoader {

    @Override
    public List<InspectorUI> getInspectorUI(Spatial spatial) throws IOException {
        LightList localLightList = spatial.getLocalLightList();
        List<InspectorUI> inspectorUIS = new ArrayList<>();
        for (Light light : localLightList) {
            //一个light 一个InspectorUI
            AttributeInspectorUI attributeInspectorUI = new AttributeInspectorUI(light.getType().name() + " Light", null);
            inspectorUIS.add(attributeInspectorUI);

            List<AttributeLoader> attributeLoaders = ExResourcesLoad.getAttributeLoaders(light);
            for (AttributeLoader attributeLoader : attributeLoaders) {
                List<Attribute> attribute = attributeLoader.getAttribute(light);
                attributeInspectorUI.addAttribute(attribute);
            }
        }
        return inspectorUIS;
    }


}
